package com.amlyc.ch03;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

public class ThreadPoolDemo {
    public static class MyTask implements Runnable{
        @Override
        public void run() {
            try {
                System.out.println(Thread.currentThread()+"id:"+Thread.currentThread().getId());
                Thread.sleep(2000);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    }

    public static void main(String[] args) {
        ExecutorService service = Executors.newCachedThreadPool();

        for (int i = 0; i < 10; i++) {
            service.submit(new Thread(new MyTask()));
        }

    }
}
